package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.DdShuaDan;
import com.ruoyi.system.service.IDdShuaDanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 抖店刷单Controller
 *
 * @author hjf
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/hmk/shuaDan")
public class DdShuaDanController extends BaseController {
    @Autowired
    private IDdShuaDanService ddShuaDanService;

    /**
     * 查询抖店刷单列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:list')")
    @GetMapping("/list")
    public TableDataInfo list(DdShuaDan ddShuaDan) {
        startPage();
        List<DdShuaDan> list = ddShuaDanService.selectDdShuaDanList(ddShuaDan);
        return getDataTable(list);
    }

    /**
     * 导出抖店刷单列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:export')")
    //@Log(title = "抖店刷单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DdShuaDan ddShuaDan) {
        List<DdShuaDan> list = ddShuaDanService.selectDdShuaDanList(ddShuaDan);
        ExcelUtil<DdShuaDan> util = new ExcelUtil<DdShuaDan>(DdShuaDan.class);
        util.exportExcel(response, list, "抖店刷单数据");
    }

    /**
     * 获取抖店刷单详细信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ddShuaDanService.selectDdShuaDanById(id));
    }

    /**
     * 新增抖店刷单
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:add')")
    //@Log(title = "抖店刷单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DdShuaDan ddShuaDan) {
        return toAjax(ddShuaDanService.insertDdShuaDan(ddShuaDan));
    }

    /**
     * 修改抖店刷单
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:edit')")
    //@Log(title = "抖店刷单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DdShuaDan ddShuaDan) {
        return toAjax(ddShuaDanService.updateDdShuaDan(ddShuaDan));
    }

    /**
     * 删除抖店刷单
     */
    @PreAuthorize("@ss.hasPermi('hmk:shuaDan:remove')")
    //@Log(title = "抖店刷单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ddShuaDanService.deleteDdShuaDanByIds(ids));
    }
}
